package crp.services.api.graphql.models;

import crp.core.workflow.domain.models.WorkflowInstanceEntity;
import crp.core.workflow.domain.models.WorkflowInstanceStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Id;
import org.eclipse.microprofile.graphql.Ignore;
import org.eclipse.microprofile.graphql.Type;

import javax.validation.constraints.NotNull;

@Type("WorkflowInstance")
@Builder
@Getter
@AllArgsConstructor
public class WorkflowInstancePayload {
    @Id
    @NotNull
    private final String id;
    @Ignore
    private final String modelId;
    @NotNull
    private final WorkflowInstanceStatus status;

    public static WorkflowInstancePayload of(WorkflowInstanceEntity entity) {
        return WorkflowInstancePayload.builder()
                .id(entity.getId())
                .modelId(entity.getModelId())
                .status(entity.getStatus())
                .build();
    }
}
